package com.day05.study;

/**
 * 找出给定字符串中子字符串的所有位置
 * 例如：给定字符串：aaa123bbb123ccc123 ，子字符串：123
 * 输出：3，9，15
 */
public class Demo04 {
    public static void main(String[] args) {
        String str = "aaa123bbb123ccc123";
        int index = 0;
        while (index != -1) {
            index = str.indexOf("123", index + 1);
            if (index != -1)
                System.out.println(index);
        }
    }
}
